package com.com.unit2.gram;
/*
* 用户消费信息类
* */
public class UserInfo {

        // 1.私有化成员变量
        private int countTalkTime;  // 统计通话时长
        private int countNetFlow;   // 统计上网流量
        private int expensePerMonth;// 每月消费金额

        // 3.在构造方法中调用set方法并进行数值的合理性判断
        public UserInfo() {
        }

        public UserInfo (int countTalkTime, int countNetFlow, int expensePerMonth) {
            this.countTalkTime = countTalkTime;
            this.countNetFlow = countNetFlow;
            this.expensePerMonth = expensePerMonth;
        }

        // 2.提供共有的get和set方法并进行数值合理性的检查
        public int getCountTalkTime() {
            return countTalkTime;
        }

        public void setCountTalkTime(int countTalkTime) {
            if(countTalkTime>=0) {
                this.countTalkTime = countTalkTime;
            } else {
                System.out.println("统计通话时长不合理哦！");
            }
        }

        public int getCountNetFlow() {
            return countNetFlow;
        }

        public void setCountNetFlow(int countNetFlow) {
            if(countNetFlow>=0) {
                this.countNetFlow = countNetFlow;
            } else {
                System.out.println("统计上网流量不合理哦！");
            }
        }

        public int getExpensePerMonth() {
            return expensePerMonth;
        }

        public void setExpensePerMonth(int expensePerMonth) {
            if(expensePerMonth>=0) {
                this.expensePerMonth = expensePerMonth;
            } else {
                System.out.println("每月消费金额不合理哦！");
            }
        }
}
